//
//  ViewController.m
//  test
//
//  Created by Jiajun Zheng on 15/6/10.
//  Copyright (c) 2015年 hgProject. All rights reserved.
//

#import "ViewController.h"
#import "ZJView.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@property (weak, nonatomic) IBOutlet UIView *topView;
@property (nonatomic, strong) UIPanGestureRecognizer *pan;
@property (nonatomic, assign) CGFloat lastX;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self addPan];
}

-(void)viewWillAppear:(BOOL)animated{
    self.topView.layer.shadowColor = [UIColor blackColor].CGColor;
    self.topView.layer.shadowOffset = CGSizeMake(-3, -1);
    self.topView.layer.shadowOpacity = 1;
}

-(void)addPan{
    self.pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
    [self.topView addGestureRecognizer:self.pan];
}

-(void)pan:(UIPanGestureRecognizer *)pan{
    CGPoint now = [pan locationInView:self.topView];
    
    if (pan.state == UIGestureRecognizerStateBegan) {
        self.lastX = now.x;
    }
    if (pan.state == UIGestureRecognizerStateChanged) {
        CGFloat delate = now.x-self.lastX;
        self.topView.center = CGPointMake(self.topView.center.x + delate, self.topView.center.y);
    }

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
